package com.yunyi.integration.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class RedisService {
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 常规推荐这个
     */
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void testRedis() {
        redisTemplate.opsForValue().set("zhangsan", "yunyi");
        String name1 = (String) redisTemplate.opsForValue().get("zhangsan");
        System.out.println("第一次获取张三:" + name1);
        stringRedisTemplate.opsForValue().set("lisi", "lisi");
        String name2 = stringRedisTemplate.opsForValue().get("lisi");
        System.out.println("第一次获取李四:" + name2);

    }


}
